﻿<%@ Page Title="Quản lý đơn đặt hàng" Language="C#" MasterPageFile="~/layout/admin.Master" AutoEventWireup="true" CodeBehind="AdminOrder.aspx.cs" Inherits="SinhNhat.admin.AdminOrder" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentHead" runat="server">
    
    <link rel="Stylesheet" type="text/css" href="/data/js/jquery.ui/jquery-ui-1.8.23.custom.css" />

</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">
    
	<script src="/data/js/jquery.ui/jquery.ui.core.js" type="text/javascript"></script>
	<script src="/data/js/jquery.ui/jquery.ui.widget.js" type="text/javascript"></script>
	<script src="/data/js/jquery.ui/jquery.ui.datepicker.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        function BeforeSearch() {
            document.getElementById("<%= hdFromDate.ClientID%>").value = document.getElementById("<%= txtFromDate.ClientID%>").value;
            document.getElementById("<%= hdToDate.ClientID%>").value = document.getElementById("<%= txtToDate.ClientID%>").value;
        }

        function AfterSearch() {
            document.getElementById("<%= txtFromDate.ClientID%>").value = document.getElementById("<%= hdFromDate.ClientID%>").value;
            document.getElementById("<%= txtToDate.ClientID%>").value = document.getElementById("<%= hdToDate.ClientID%>").value;
        }
    </script>
    
    <asp:HiddenField ID="hdFromDate" runat="server" />
    <asp:HiddenField ID="hdToDate" runat="server" />
    <asp:HiddenField ID="hdFirst" runat="server" />

    <div>
        <h2>Danh sách đơn đặt hàng</h2>
        <h3>Bộ lọc</h3>
        <hr />

        <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true" />

        <table >
            <tr>
                <td>Từ ngày:</td>
                <td>
                    <asp:TextBox ID="txtFromDate" runat="server" ReadOnly="true" />
                </td>
                <td>Đến ngày:</td>
                <td>
                    <asp:TextBox ID="txtToDate" runat="server" ReadOnly="true" />
                </td>
                <td style="padding-left:20px;">
                    <asp:Button ID="btnSearch" runat="server" Text="Search" OnClientClick="BeforeSearch();" />
                </td>
            </tr>
        </table>
        <hr />

    </div>

    <script type="text/javascript">
        $(function () {
            $("#<%=txtFromDate.ClientID%>").datepicker({
                dateFormat: "dd/mm/yy",
                showOn: "button",
                buttonImage: "/data/images/calendar.gif",
                buttonImageOnly: true
            });

            $("#<%=txtToDate.ClientID%>").datepicker({
                dateFormat: "dd/mm/yy",
                showOn: "button",
                buttonImage: "/data/images/calendar.gif",
                buttonImageOnly: true
            });
        });
	</script>

    <div>
        <h3>
            <asp:Label ID="lblHeader" runat="server"/>
        </h3>

        <asp:GridView ID="grOrder" runat="server" AutoGenerateColumns="False" AllowPaging="true" PageSize="20"
            DataKeyNames="OrderID" BackColor="White" BorderColor="#999999" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
            <AlternatingRowStyle BackColor="#DCDCDC" />
            
            <Columns>
                <asp:TemplateField HeaderText="STT" ItemStyle-Width="30px">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tên khách hàng" ItemStyle-Width="200px"><ItemTemplate>
                        <%# Eval("CustomerName")%>
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Số điện thoại" ItemStyle-Width="150px"><ItemTemplate>
                        <%# Eval("CustomerPhone")%>
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Hình thức thanh toán" ItemStyle-Width="150px"><ItemTemplate>
                        <%# Eval("PAYMENT.Name")%>
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày đặt" ItemStyle-Width="150px"><ItemTemplate>
                        <%# Eval("CreateDate")%>
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Giá trị" ItemStyle-Width="150px"><ItemTemplate>
                            <%# string.Format("{0:N0} VNĐ", Eval("Amount")) %> 
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Trạng thái" ItemStyle-Width="100px"><ItemTemplate>
                        <asp:ImageButton ID="btnActice" runat="server" ImageUrl=<%# ((Boolean)Eval("Status"))?"/data/images/Success.png":"/data/images/waiting.jpg" %>
                            CommandArgument='<%# Eval("Status")%>' 
                            CommandName='<%# Eval("OrderID")%>' />
                            
                            <%# ((Boolean)Eval("Status")) ? "Đã xử lý" : "Chưa xử lý"%>
                    
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Xem chi tiết" ItemStyle-Width="70px"><ItemTemplate>
                        <a href=<%# "/admin/EditOrder.aspx?orderID=" + Eval("OrderID")%>>
                            Xem
                        </a>
                    
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#0000A9" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#000065" />
        </asp:GridView>

        <div style="text-align:right; padding-top:20px;">
        
            Tổng giá trị:
            <asp:Label ID="lblSum" runat="server" Font-Bold="true" ForeColor="Red"/> <br />
            <i>* Giá trị chỉ bao gồm các đơn hàng đã xử lý</i>
            
        </div>
    </div>
    

</asp:Content>
